/**
* Created by wl
* 项目管理>持有中-详情页-高管/股东-股东信息
*/
<template>
    <div class="ca-box ca-m-t-28 ca-p-20">
        <div v-if="!showEdit">
            <div class="ca-title">
                <h3>股东信息</h3>
                <el-button type="text" class="ca-edit-btn el-icon-edit ca-m-r-10 edit-btn" @click="editInfo" :disabled="!isAuthIndexSee">编辑</el-button>
            </div>
            <div>
                <div class="ca-m-t-28" v-for="(item, index) in fileTime" :key="index">
                    <h3>时间：{{$moment(item).format('YYYY-MM-DD')}}</h3>
                    <table class="ca-table ca-m-t-15">
                        <tr>
                            <th>序号</th>
                            <th v-for="(title, ind) in fileList[item][0]" :key='ind'>{{title}}</th>
                        </tr>
                        <tr v-for="(value, ind) in fileList[item][1]" :key="ind">
                            <td>{{ind+1}}</td>
                            <!-- <td>{{value}}</td> -->
                            <td v-for="(val, ind) in value" :key='ind'>{{val}}</td>
                        </tr>
                    </table> 
                </div>
            </div>
        </div>
        <csShareholder v-else :showBtn="true" @close="close" @save="save"></csShareholder>
    </div>
</template>
<script type="text/ecmascript-6">
    import {api} from '../../api';
    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
    import { addRemind, isNoAuth } from '__service/utils';
    export default {
        data() {
            return {
                isAuthIndexSee: isNoAuth('持有中项目-高管/股东-编辑'),
                showEdit: false,
                value: '',
                fileTime: [],
                fileList: {},
            }
        },
        watch: {
        },
        props: {},
        mounted() {
            this.getInfo()
        },
        methods: {
            editInfo() {
                this.showEdit = true
            },
            close() {
                this.showEdit = false
            },
            async save() {
                await this.getInfo()
                // 添加小红点
                await addRemind({
                    dataId: this.$route.params.itemId, // 业务id
                    dataTab: 1, // tab页顺序 head 也为0 新建为'-1'
                    dataType: 2, // 1拟投资项目,2已投资项目,3母基金,4拟设立基金,5已设立基金,6客户,7潜在项目
                });
                // 根据第三方组件来调用 父组件中定义的方法 重新获取小红点
                this.$root.Dot.$emit('getDotList');
                // 添加小红点 end
            },
            getInfo() {
                this.fileTime = []
                apiHttp(api.CHECK_SHAREHOLDER, {itemId: this.$route.params.itemId}).then(ret=> {
                    if (ret.resCode === STATUS_HTTP_SUCCESS) {
                        this.fileTime = Object.keys(ret.data)
                        this.fileList = ret.data
                        let fileList = ret.data
                        for ( let aa in fileList) {
                              let arr = []
                           for (let i = 1; i < fileList[aa].length; i++ ) {
                             arr.push(fileList[aa][i])
                           }
                           fileList[aa][1] = arr
                        }
                    }
                })
            },
        },
        components: {
            csShareholder: require('./edit'),
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.edit-btn {
    float: right;
    cursor: pointer;
}
.el-right {
    float: right;
}
.el-info {
    font-size: 22px;
    color: #ccc;
    padding: 20px;
}
</style>